#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>

struct node
{    int item;
     struct node *next;
}*head;

void append(int x)
{   struct node *p1;
    struct node *new=malloc(sizeof(struct node));
    if(new==NULL)
     printf("\n Invalid");
    else
    { new->item=x;
      new->next=NULL;
    }
    if(head==NULL)
      head=new;
    else
    {   for(p1=head;p1->next!=NULL;p1=p1->next)
           p1->next=new;
    }   
    printf("\n\tElement appended\n");
}

void Display()
{ struct node *p;
  for(p1=head;p1!=NULL;p1=p1->p)
  {   if(p1!=head)
        printf(", ");   
      printf("%d",p1->item);
  }
}

void Index(int x)
{   struct node *p;
    int ctr=0,flag=0;
    for(p1=head;p1!=NULL;p1=p1->next)
    {   if(p1->item==x)
        {   flag=1;
            printf("The position is %d",ctr);
            break;
        }
        ctr++;
    }
    if(flag==0)
    {   printf("\n\tValue not found");
    }
}

void Count(int x)
{   struct node *p;
    int ctr=0;
    for(p1=head;p1!=NULL;p1=p1->next)
    {   if(p1->item==x)
           ctr++;
    }
    printf("%d",ctr);
}

int main(void)
{
  int len,i,choice,x;
  char ch;
  printf("Enter an element ");
  scanf("%d",&x);
  append(x);
  }
do
{
printf ("1.Insert/2.Append/3.Extend/4.Delete/5.Pop/6.Index/7.Count/8.Sort/9.Reverse/10.Display/11.Quit \n ");
scanf("%d",&choice);
switch(choice)
{
case 1:break;
case 2:{printf("Enter an element ");
        scanf("%d",&x);
       append(x);
       print();
       break;
       }
case 3:break;
case 4:break;
case 5:break;
case 6:{ printf("Enter an element ");
        scanf("%d",&x);
         Index(x);
       break;
       }
case 7:{ printf("Enter an element ");
        scanf("%d",&x);
         Count(x);
       break;
       }
case 8:
       break;
case 9:
       break;
case 10:Display(list,len);
	break;
case 11:return 0;
        break;

}

printf("You want to Continue Y/N ?");
scanf("%s",&ch);
}while(ch!='N' && ch!='n');
}

